package cn.edu.scau.cmi.liujianxun.client.fxUI.abstractFactory;

import javafx.fxml.FXML;

import javafx.scene.control.Button;
import cn.edu.scau.cmi.liujianxun.abstractFactory.factory.AbstractFactory;
import cn.edu.scau.cmi.liujianxun.abstractFactory.insuranceAbstractClass.Insurance;
import javafx.scene.control.Label;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.image.ImageView;

public class AbstractFactoryDemoController {
	@FXML
	private Label lbName;
	@FXML
	private Label lbNum;
	@FXML
	private ComboBox<String> insuranceCbBox;
	@FXML
	private ComboBox<String> companyCbBox;
	@FXML
	private TextArea textArea;
	@FXML
	private ImageView imageView;
	@FXML
	private Button bt;

	String[] company = {"中国人寿保险", "平安保险"};
	String[] insurance = {"司机受伤", "汽车损坏", "人员伤亡", "多种事故"};
	
	public AbstractFactoryDemoController() {
		
	}
	public void init() {
		insuranceCbBox.getItems().addAll(insurance);
		companyCbBox.getItems().addAll(company);
	}
	
	public void btEvent() {
		String i = insuranceCbBox.getValue();
		String c = companyCbBox.getValue();
		
		AbstractFactory company = AbstractFactory.getFactory(c);
		Insurance insur = null;
		
		switch(i)
		{
		case "司机受伤": insur = company.createBodyInjur();break;
		case "汽车损坏": insur = company.createCollision();break;
		case "人员伤亡": insur = company.createPersonInjur();break;
		case "多种事故": insur = company.createComprehensive();break;
		default : break;
		}
		
		String result = insur.getInsurInfo();
		
		textArea.appendText(result + '\n');
	}
}
